<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./../template/WorkspaceTemplate.xhtml">

    <ui:define name="top">

    </ui:define>

    <ui:define name="left">

    </ui:define>

    <ui:define name="right">

    </ui:define>

    <ui:define name="content">

        <h:form id="storeInvoiceForm" style="font-size: 85%">
            <h2>View Supplier Invoice</h2>
            <br/>
            <p:panel>
                <p:messages id="messages" />
                <h:panelGrid columns ="6" cellpadding="10">
                    <h:outputLabel value="Sales Order Reference: " style="font-weight: bold"/>
                    <h:outputText id="soNumber" value="#{supplierInvoiceManagerBean.invoice.rmso.salesOrderId}"/>
                    <p:commandButton update="viewSOForm" oncomplete="soDialog.show();" image="ui-icon ui-icon-search" />
                    <h:outputText value=""/>
                    <h:outputLabel value="Invoice Date: " style="font-weight: bold"/>
                    <h:outputText value="#{supplierInvoiceManagerBean.invoice.dateCreated}">
                        <f:convertDateTime pattern="MMMM dd, yyyy"/>
                    </h:outputText>

                    <h:outputLabel value="Supplier Id: " style="font-weight: bold"/>
                    <h:outputText id="supplierId" value="#{supplierInvoiceManagerBean.invoice.supplier.supplierId}"/>
                    <h:outputText value=""/>
                    <h:outputText value=""/>
                    <h:outputLabel value="Invoice Number: " style="font-weight: bold"/>
                    <h:outputText value="#{supplierInvoiceManagerBean.invoice.supplierInvoiceNo}" />

                    <h:outputLabel value="Supplier Name: " style="font-weight: bold"/>
                    <h:outputText id="supplierName" value="#{supplierInvoiceManagerBean.invoice.supplier.supplierName}"/>

                </h:panelGrid>

                <br/>
                <br/>
                <br/>
                <h:outputText value="Order Items" style="font-weight: bold; font-size: 110%"/>
                <p:separator/> 
                <br/>
                <p:dataTable id="items" var="rec" rowIndexVar="row" value="#{supplierInvoiceManagerBean.invoice.itemLines}" emptyMessage="No items added.">
                    <p:column headerText="S/N" >
                        <h:outputText value="#{row + 1}"/>
                    </p:column>

                    <p:column headerText="Raw Material Item">
                        <h:outputText value="#{rec.rawMaterialSupplyInformation.rawMaterial.name}"/>
                    </p:column>

                    <p:column headerText="Quantity">
                        <h:outputText value="#{rec.qty}"/>
                    </p:column>
                    

                </p:dataTable>

                <br/>
                <br/>
                <br/>
                <h:outputText value="Payment Details" style="font-weight: bold; font-size: 110%"/>
                <p:separator/> 
                <br/>
                <h:panelGrid columns="2" cellpadding="10">
                    <h:outputLabel style="font-weight: bold" value="Currency: "/>
                    <h:outputText value="#{supplierInvoiceManagerBean.invoice.currency?'SGD':'USD'}"/>

                    <h:outputLabel style="font-weight: bold" value="Total Amount: "/>
                    <h:outputText value="#{supplierInvoiceManagerBean.invoice.invoiceAmount}"/>

                </h:panelGrid>

                <br/>
                <br/>
                <br/>
                <h:outputText value="Supplier Invoice File" style="font-weight: bold; font-size: 110%"/>
                <p:separator/> 
                <br/>
                <p:graphicImage value="#{facesContext.externalContext.requestContextPath}/../displayImage?id=#{supplierInvoiceManagerBean.invoice.uploadedImage.id}" width="100%"/>
                <br/>
            </p:panel>

            <br/>
            <br/>
            
        </h:form>
        

    </ui:define>

    <ui:define name="bottom">

    </ui:define>

</ui:composition>